﻿using System.Web.Security;
using AspNetMvc.Providers;

namespace AspNetMvc.Services.Authentication
{
   /// <summary>
   /// Membership service interface
   /// </summary>
   public interface IMembershipService
   {
      /// <summary>
      /// Gets minimum password length
      /// </summary>
      int MinPasswordLength { get; }

      /// <summary>
      /// Validates user
      /// </summary>
      /// <param name="userName">Username</param>
      /// <param name="password">Password</param>
      /// <returns></returns>
      bool ValidateUser(string userName, string password);

      /// <summary>
      /// Validates user
      /// </summary>
      /// <param name="userName">Username</param>
      /// <param name="password">Password</param>
      /// <returns></returns>
      bool ValidateUser(string openIdUrl, IOpenIdUserInfo info);

      /// <summary>
      /// Approves user with the key specified
      /// </summary>
      /// <param name="confirmationKey">Confirmation key</param>
      /// <returns></returns>
      MembershipUser ApproveUser(string confirmationKey);

      /// <summary>
      /// Creates user
      /// </summary>
      /// <param name="userName">Username</param>
      /// <param name="password">Password</param>
      /// <param name="email">E-mail address</param>
      /// <returns>Creation status</returns>
      MembershipCreateStatus CreateUser(string userName, string password, string email, string lang, string confirmationLinkFormat, object userProviderKey);

      /// <summary>
      /// Creates user
      /// </summary>
      /// <param name="userName">Username</param>
      /// <param name="password">Password</param>
      /// <param name="openIdUrl">OpenId URL</param>
      /// <returns>Creation status</returns>
      MembershipCreateStatus CreateUser(string username, string openIdUrl, string lang, IOpenIdUserInfo info);

      /// <summary>
      /// Changes password
      /// </summary>
      /// <param name="userName">Username</param>
      /// <param name="oldPassword">Old password</param>
      /// <param name="newPassword">New password</param>
      /// <returns></returns>
      bool ChangePassword(string userName, string oldPassword, string newPassword);

      /// <summary>
      /// Returns a username which is associated with the URL specified
      /// </summary>
      /// <param name="openIdUrl">OpenId URL</param>
      /// <returns></returns>
      string GetUsernameFromOpenId(string openIdUrl, IOpenIdUserInfo info);
   }
}